package com.chen.root.base;

import lombok.Data;

import java.io.Serializable;

/**
 * @author ChenJinLong
 */
@Data
public class FileChunk implements Serializable {

    /** 文件路径 **/
    private String filePath;

    /** 块大小 **/
    private Integer chunkSize;

    /** 当前块, 从1开始 **/
    private Integer currChunk;

    public static Integer totalChunk(Long length, Integer chunkSize){
        return (int) Math.ceil(length / chunkSize.doubleValue());
    }

    /** 获取偏移量 **/
    public long offset(){
        return (long) this.chunkSize * (this.currChunk - 1);
    }

}
